<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes">
  
  
  <title>  SpringBoot 部署记录 |   XHX 博客 </title>

 
  
    <link rel="icon" href="/images/favicon.ico">
  


  <link rel="stylesheet" href="/nayo.min.css"> 
</head>  
  <body>   
    
      <header class="header">
	
  <nav class="header-nav">        

    <span class="iconfont icon-menu mobile-toggle"></span>   	

    <div class="header-logo">
      <a href="/">
        <img class="header-logo-img" src="/images/head.JPG">
      </a>
    </div>

    <div class="header-menu">          
              
          
            <a class="header-menu-link" id="header-menu-home" href="/">
              <i class="iconfont icon-home">  
            </i></a>     
          
              
          
            <a class="header-menu-link" id="header-menu-archives" href="/archives">
              <i class="iconfont icon-archives">  
            </i></a>     
          
              
          
            <a class="header-menu-link" id="header-menu-tags" href="/tags">
              <i class="iconfont icon-tags">  
            </i></a>     
          
              
          
            <a class="header-menu-link" id="header-menu-about" href="/about">
              <i class="iconfont icon-about">  
            </i></a>     
          
              
          
              <a class="header-menu-link" id="header-menu-search">
                <i class="iconfont icon-search">  
              </i></a>
          
                  
    </div>  
    
  </nav>
</header>

   

      <div class="container">       
          
          
            <section class="main">  
          

          <article class="post">
  
	<div class="post-header">

	<p class="post-title">	
		SpringBoot 部署记录
	</p>
			

	<div class="meta-info">	
	<span>
		Jan 07, 2019
	</span>

	
	
		<i class="iconfont icon-words"></i>
		<span>
			1411
		</span>
	
</div>

</div> 
	 

	  <div class="typo post-content slideDownMin">

		

			
					<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>&nbsp;&nbsp;跟着书上的教程完成了一个简单的SpringBoot的用户管理的项目。想用github来实现版本控制，同时接触一点简单的发布版本的知识。所以打算发布一个RELEASE试试。<br><a id="more"></a></p>
<h1 id="1-发布"><a href="#1-发布" class="headerlink" title="1. 发布"></a>1. 发布</h1><p>&nbsp;&nbsp;在mac的IntelliJ IDEA将项目同步到github上，然后给这个commit发布了一个RELEASE。具体的发布RELEASE其实没有什么知识，跟着github的指引就行了：选择一个branch，填写版本号（建议的命名格式：v1,0，v1.1-alpha等），填写发布信息（增加了什么功能，有哪些修改等信息），添加版本附件（比如desktop应用的exe，java的包jar或war等），就可以直接发布了。</p>
<p><img src="https://xiaohaoxing-1257815318.cos.ap-chengdu.myqcloud.com/blog/release-config.jpg" alt="版本发布编辑界面"></p>
<p>&nbsp;&nbsp;但是我build的jar包一直上传失败！客户端只能先编译再部署了！</p>
<h1 id="2-部署"><a href="#2-部署" class="headerlink" title="2. 部署"></a>2. 部署</h1><p>&nbsp;&nbsp;紧接着就需要在客户机上部署了。切换到windows机器上，先在浏览器上下载下来source code 包（包括zip格式和tar.gz格式）。这里为了方便我直接用windows的winzip软件解压了，而没有用Linux的解压命令。然后打开Windows Subsystem Linux，开始从源码构建部署项目。<br>&nbsp;&nbsp;我开始就用的开发机上的<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 运行 build</span></span><br><span class="line">gradle build</span><br></pre></td></tr></table></figure></p>
<p>命令去运行，提示：command gradle not found! 赶紧<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 安装 gradle</span></span><br><span class="line">sudo apt-get install gradle</span><br></pre></td></tr></table></figure></p>
<p>装一下gradle。重新运行上述命令：build failed! Need gradle version 4.4+,found 3.4.这就很奇怪了，我用apt-get获取的为什么还不是最新版本的？改用命令：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 明确版本</span></span><br><span class="line">sudo apt-get install gradle=4.4</span><br></pre></td></tr></table></figure></p>
<p>提示：version 4.4 not found! 难道linux的gradle版本系列和mac上的不同？这时候想到书上看过的一条信息：用gradlew（Linux系统）或者gradlew.bat命令运行Gradle Wrapper脚本，就可以规避由环境不一致引起的编译失败问题！（书上的坑都被我踩了个遍！）于是去运行<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># gradle 构建环境的搭建</span></span><br><span class="line">./gradlew</span><br></pre></td></tr></table></figure></p>
<p>运行成功！然后用<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 正式的 build</span></span><br><span class="line">./gradlew build</span><br></pre></td></tr></table></figure></p>
<p>去重新构建项目。<br>&nbsp;&nbsp;等待Build Success信息出来。这时候项目目录下就已经生成了build目录，打开build/lib， 看到我们的项目生成的jar包已经在这里了！执行<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 部署项目</span></span><br><span class="line">java -jar SpringBootBook-1.1.0.RELEASE.jar</span><br></pre></td></tr></table></figure></p>
<p>去部署项目！<br><img src="https://xiaohaoxing-1257815318.cos.ap-chengdu.myqcloud.com/blog/deploy-result.jpg" alt="部署结果"></p>
<h1 id="3-运行"><a href="#3-运行" class="headerlink" title="3. 运行"></a>3. 运行</h1><p>&nbsp;&nbsp;等控制台显示出:Started Application in XX.XX s.就表示项目已经成功部署在机器上了！这时候去访问网页就能看到项目的结果了：<br><img src="https://xiaohaoxing-1257815318.cos.ap-chengdu.myqcloud.com/blog/run-result.jpg" alt="运行结果"></p>
<h1 id="4-总结"><a href="#4-总结" class="headerlink" title="4. 总结"></a>4. 总结</h1><p>&nbsp;&nbsp;以上就是项目的一个版本从发布到部署运行的全过程，可能会有一些坑需要踩。不过我个人觉得 Gradle 提供的构建方式对部署已经非常友好了，以上的过程基本比较顺利的一晚上就完成了。和 github 的 release 配合起来对于运维来说体验极好！该项目后续更多的是对 Spring Boot 的深入探究，部署过程将不再是重点了！</p>
  	
					
	  </div>     
	  

	<div class="post-footer">

  <div class="post-footer-other">
      <span class="post-footer-item">
        




<span class="donate-btn">
	<span class="iconfont icon-donate"></span>
</span>


<div id="donate-box" class="sildeUpMin">

	<span class="donate-cancel iconfont icon-cancel"></span>

	<div class="donate-img-box">
		<img id="donate-qr-wechat" class="noLazyLoad donate-img" src="/images/donate1.png" alt="No Donate Image!">	
		<img id="donate-qr-alipay" class="noLazyLoad donate-img lazyload" src="/images/placeholder.png" alt="No Donate Image!" data-src="/images/donate2.png">	
	</div>

	<span class="donate-word">希望本文对你有帮助~</span>

	<div class="donate-list">
		<span class="iconfont icon-donate-wechat"></span>
		<span class="iconfont icon-donate-alipay"></span>
	</div>

</div>

 
      </span>           
      <span class="post-footer-item">
        
	
<script id="-mob-share" src="http://f1.webshare.mob.com/code/mob-share.js?appkey=29a4323345125"></script>
	
	<span class="share-btn">
	<span class="iconfont icon-share"></span>
	</span>


	<div class="-mob-share sildeUpMin">
		<div class="-mob-inner">
		   			             
            <a class="iconfont icon-share-qq -mob-share-link"></a>		
     	   			             
            <a class="iconfont icon-share-weixin -mob-share-link"></a>		
     	   			             
            <a class="iconfont icon-share-weibo -mob-share-link"></a>		
     	   
		</div>
	</div>	

      </span>           
  </div>  

  <div class="post-footer-meta">
        	

        
          <i class="iconfont icon-tag"></i>     
            <a class="tag-link" href="/tags/Java/">Java</a> <a class="tag-link" href="/tags/SpringBoot/">SpringBoot</a>    
        	
  </div>

</div>


<nav class="post-footer-nav">
  
    <div class="post-footer-link">
      <a href="/2019/01/09/Spring-Boot-项目application-properties配置详情/" id="post-nav-newer" class="post-nav-link-wrap">
        <strong class="post-nav-caption">newer</strong>
           
          <a class="post-nav-title" href="/2019/01/09/Spring-Boot-项目application-properties配置详情/">
          Spring Boot 项目application.properties配置详情</a>
      </a>
    </div>
  
  
    <div class="post-footer-link">
      <a href="/2018/10/12/数据库中-Blob-数据类型探究/" id="post-nav-older" class="post-nav-link-wrap">
        <strong class="post-nav-caption">older</strong>
        
          <a class="post-nav-title" href="/2018/10/12/数据库中-Blob-数据类型探究/">
          数据库中 Blob 数据类型探究</a>
      </a>
    </div>
  
</nav>
 
	


    
    <div id="disqus_thread"></div>

    <script>
    (function() { 
    var d = document, s = d.createElement('script');
    s.src = 'https://'+'xiaohaoxing-github-io'+'.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());    
    (d.head || d.body).appendChild(s);
    })();
    </script>

    <noscript>Please enable JavaScript to view the  <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
    </noscript>


	
</article>

          </section> 
      </div>            
    
    <a id="backTop">
      <span>
        <i class="iconfont icon-backtotop"></i>
      </span>
    </a> 

  
    
    <div class="search-container sildeUpMin">
        <div class="search-header">
            <input type="text" placeholder="输入你想搜索的" id="search-input" class="search-input">
            <span class="search-cancel">
                <i class="iconfont icon-cancel">
            </i></span>
        </div>
        <div id="search-result" class="search-result"></div>
    </div>
 
     <div class="mobile-menu">      

      
      <img class="mobile-menu-icon lazyload" src="/images/placeholder.png" data-src="/images/favicon.ico">   
      

         
            

            <a class="mobile-menu-link" href="/">首頁
            </a>
            
         
            

            <a class="mobile-menu-link" href="/archives">歸檔
            </a>
            
         
            

            <a class="mobile-menu-link" href="/tags">標籤
            </a>
            
         
            

            <a class="mobile-menu-link" href="/about">關於
            </a>
            
         
                          

            <a class="mobile-menu-link mobile-menu-search" href="#">搜索 </a>                 
            
         
      
</div>        
    



     
    




<footer id="footer">	    

		
		<div class="footer-copyright">
		&copy;
				
		2018-
		
		2019		
	
		XiaoHaoxing
		<br>

		Theme By
		<a href="https://github.com/Lemonreds/hexo-theme-Nayo" target="_blank">Nayo</a>	
		</div>			
		<script src="https://s19.cnzz.com/z_stat.php?id=1274862886&web_id=1274862886" language="JavaScript"></script>
</footer>   

  

    <script src="/nayo.bundle.js"></script>           
  </body>        
</html>